//
//  ThirdlubTableViewCell.m
//  Project_B
//
//  Created by dllo on 15/11/24.
//  Copyright © 2015年 张闯. All rights reserved.
//

#import "ThirdlubTableViewCell.h"
#import "ThirdlubModel.h"
#import "UIImageView+WebCache.h"

@interface ThirdlubTableViewCell ()

@property (nonatomic, retain) UILabel *title;
@property (nonatomic, retain) UILabel *subtitle;
@property (nonatomic, retain) UIImageView *image;

@end

@implementation ThirdlubTableViewCell

#pragma mark - 初始化
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.title = [[UILabel alloc] init];
        [self.contentView addSubview:self.title];
      
        
        self.subtitle = [[UILabel alloc] init];
        [self.contentView addSubview:self.subtitle];
     
        
        self.image = [[UIImageView alloc] init];
        [self.contentView addSubview:self.image];
      
    }
    return self;
}
#pragma mark - 布局
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.image.frame = CGRectMake(10, 5, 50, 50);
    self.image.layer.cornerRadius = 25;
    self.image.clipsToBounds = YES;
    
    self.title.frame = CGRectMake(self.image.frame.origin.x + self.image.frame.size.width + 10, self.image.frame.origin.y + 5, 200, 17);
    self.title.textColor = [UIColor blackColor];
    
    self.subtitle.frame = CGRectMake(self.title.frame.origin.x, self.title.frame.origin.y + 25 , self.contentView.frame.size.width - 100, 15);
    self.subtitle.textColor = [UIColor lightGrayColor];
    self.subtitle.font = [UIFont systemFontOfSize:14];
}

- (void)setModel:(ThirdlubModel *)model
{
    if ([model.title containsString:@"砾石"]) {
        NSString *str = [model.title stringByReplacingOccurrencesOfString:@"砾石" withString:@"砾石思行"];
        self.title.text = str;
    } else {
        self.title.text = model.title;
    }
    
    self.subtitle.text = model.topic_title;
    
    
    [self.image sd_setImageWithURL:[NSURL URLWithString:model.image] placeholderImage:[UIImage imageNamed:@"zhanwei.png"]];

}

- (void)awakeFromNib {
    // Initialization code
    
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    // Configure the view for the selected state
    
    
    
}

@end
